#include <vector>
#include <algorithm>
using namespace std;
class Solution
{
public:
    int findNumberOfLIS(vector<int> &nums)
    {
        // dp[i] 以i为结尾的子序列长度
        vector<int> dp(nums.size(), 1);
        // 多少个
        vector<int> dp_num(nums.size(), 1);
        for (int i = 1; i < dp.size(); i++)
        {
            for (int j = 0; j < i; j++)
            {
                if (nums[i] > nums[j])
                {
                    if (dp[j] + 1 > dp[i])
                        dp[i] = dp[j] + 1, dp_num[i] = dp_num[j];
                    else if (dp[j] + 1 == dp[i])
                        dp_num[i] += dp_num[j];
                }
            }
        }
        int max_ele = *max_element(dp.begin(), dp.end());
        int ans = 0;
        for (int i = 0; i < dp_num.size(); i++)
            if (dp[i] == max_ele)
                ans += dp_num[i];
        return ans;
    }
};